package com.xone.xapp;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class TurnOnOffActivity extends Activity {
	
	protected Context mContext = this;
	protected boolean isTurnOn = true;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.turn_on_off);
		final TextView tv = (TextView) this.findViewById(R.id.turn_on_off_btn);
		tv.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (isTurnOn) {
					isTurnOn = false;
					tv.setText("关");
					tv.setBackgroundDrawable(mContext.getResources()
							.getDrawable(R.drawable.off_background));
				} else {
					isTurnOn = true;
					tv.setText("开");
					tv.setBackgroundDrawable(mContext.getResources()
							.getDrawable(R.drawable.on_background));
				}
			}
		});
	}
}
